<?php
require_once MODEL_PATH.DS.'Product.php';
require_once MODEL_PATH.DS.'Category.php';
require_once MODEL_PATH.DS.'Brand.php';
require_once MODEL_PATH.DS.'ProductImage.php';
$Product = new Product();
$Category = new Category();
$Brand = new Brand();
$ProductImage = new ProductImage();
$product_id = isset($_GET['product_id'])?(int)$_GET['product_id']:'';

if($product_id){
	$cat_list = $Category->getAllCategories();
	$Product->increView($product_id);
	$product_info = $Product->getProductDetailById($product_id);
	$brand_info = $Brand->getBrandById($product_info['manufacturer_id']);
	
	$imgs = $ProductImage->getProductImgByPid($product_id);
	$tpl->assign('product_info',$product_info);
	$tpl->assign('cat_list',$cat_list);
	$tpl->assign('brand_name',$brand_info['name']);
	$tpl->assign('img_list',$imgs);
	$tpl->display('product_view.tpl');
}
?>